<?php
namespace app\erp_meixingtiyu\model;
use think\Model;
use app\common\model\UploadFile;

class Banner extends Model
{
    protected $table = 'athlon_banner';
    protected $pk = 'banner_id';

    public function image()
    {
        return $this->hasOne(UploadFile::class, 'file_id', 'image_id');
    }

    public function getList()
    {
      return $this->with(['image'])
            ->order('sort', 'asc')
            ->paginate(15);
    }

    public static function addBanner($data)
    {
        return self::create($data);
    }

    public static function editBanner($data)
    {
      return self::update($data);
    }

    public function deleteBanner()
    {
      return $this->delete();
    }

    public static function getAll()
    {
      return self::with(['image'])->select();
    }

}
